<template>
  <div>
    <el-container>
      <el-header>
        <span>右手左手公司系统</span>
        <span
          >个人中心<el-button @click="logout" type="info"
            >{{ $store.state.userInfo.nickname }}注销</el-button
          ></span
        >
      </el-header>
      <el-container>
        <el-aside width="220px">
          <infinite-nav></infinite-nav>
        </el-aside>
        <el-main>
          <router-view> </router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
// import New from './components/New.vue';

import InfiniteNav from "@/components/InfiniteNav";
import { logoutApi } from "@/api/apis";
export default {
  name: "AppContext",
  components: {
    InfiniteNav,
    // New,Old,
  },
  props: {
    sampleP: {
      type: Number,
      default: 0,
    },
  },
  data() {
    return {
      sampleD: "value",
    };
  },
  computed: {
    // sampleC() {
    //     return this.sampleD+'--';
    // }
  },
  created() {},
  mounted() {},
  methods: {
    sampleM() {},
    logout() {
      // this.$http({
      //   method: "get",
      //   url: "/logout",
      // })
      logoutApi().then(
        (res) => {
          this.$message.warning(JSON.stringify(res.data));
          let _username = this.$store.state.userInfo.username;
          //  清空数据 路由导航
          //   vuex 数据要清除
          //   sessionStorage;
          //   localStorage
          this.$store.commit("cleanAuth");

          this.$router.push({
            path: "/logon",
            query: {
              username: _username,
            },
          });
        },
        (error) => {
          console.log(" request error : " + error.response.status);
        }
      );
    },
  },
  watch: {
    // sampleC(newValue, oldValue) {
    //
    // }
  },
};
</script>

<style lang="scss" scoped>
.el-header {
  background-color: rgba(244, 112, 11, 0.71);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.el-aside {
  background-color: rgba(40, 216, 137, 0.71);
}
.el-main {
  background-color: rgba(216, 76, 18, 0.71);
}
</style>
